headerCommon();
layui.use('carousel', function () {
    var carousel = layui.carousel;
    //建造实例
    carousel.render({
        elem: '#test1'
        , width: '1235px' //设置容器宽度
        , height: '550px'
        , arrow: 'always' //始终显示箭头
    });
});
const imgDom = document.querySelectorAll('#test1 img')
ajax({
    url: baseUrl + '/system/homeSlide',
    success: function (response) {
        response.data.forEach((item, key) => {
            imgDom[key].src = item.imgUrl;
        });
    }
})
const oneUlDom = document.querySelector('.layui-carousel .one_ul');
let html = '';
window.addEventListener('load', async () => {
    let { data } = await pajax({url: baseUrl + '/system/category'});
   console.log(data)
    data.forEach((item,key) => {
        if(key>12) return;
        html += `<li class='one_li'>
        <a href='first.page.html?id=${item.id}'>${item.cateName}</a>
        <div class='right'><ul class='two_ul'>`
        item.children&&item.children.forEach((second,secondIndex)=>{
            html+=`<li class='two_li'><a href=''><img src='${second.icon}'>${second.cateName}</a><ul class='three_ul'>`
            second.children && second.children.forEach(three=>{
                html += `<li class='three_li'><a href=""><img src='${three.icon}'>${three.cateName}</a></li>`
            })
            html+=`</ul></li>`
        })
        html+=`</ul></div></li>`
    })
    oneUlDom.innerHTML = html;
})



